﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OpenPhotoAlbum.Controls
{
	public partial class CommentList : System.Web.UI.UserControl
	{
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
			{
				scriptManagerProxy.Services.Add(new ServiceReference("~/My/Comments.asmx"));
			}
		}

		public bool IsCommentsOwner
		{
			get
			{
				if (HttpContext.Current.User.IsInRole(BusinessLogics.RoleNames.Administrator)) { return true; }
				string userName = BusinessLogics.PhotoManager.Instance.GetUserName(UrlContext.PhotoId);
				return userName.Equals(HttpContext.Current.User.Identity.Name, StringComparison.InvariantCultureIgnoreCase);
			}
		}
	}
}